﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DTO;
using BUS;

namespace TVC_WEB.Admin.UserControl
{
    public partial class UsrTop : System.Web.UI.UserControl
    {
        public string strUsername;
        string _sErr = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UsernameAdmin"] == null)
            {
                Response.Redirect("~/Admin/Login.aspx");
                return;
            }
            else
            {
                strUsername = Session["UsernameAdmin"].ToString();
            }
            if (!Page.IsPostBack)
            {
                AdminInfo admin = new AdminInfo();
                admin.Username = strUsername;
                AdminControl adminControl = new AdminControl();
                int idAdmin = adminControl.IsExist(admin.Username);
                if (idAdmin != -1)
                {
                    admin = adminControl.Get(idAdmin, ref _sErr);
                    this.lblFullname.Text = admin.FullName;
                }

            }
        }
        protected void btnLogout_Click(object sender, EventArgs e)
        {
            Session["UsernameAdmin"] = null;
            Response.Redirect("~/Default.aspx");
        }

        protected void btnChangePassword_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/Page/ChangePass.aspx");
        }
    }
}